package qqserver.service;

import java.util.HashMap;
import java.util.Set;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class ManageServerConnectClientThread {
    private static HashMap<String,ServerConnectClientThread> hm = new HashMap<>();

    public static HashMap<String, ServerConnectClientThread> getHm() {
        return hm;
    }

    //静态方法，用于将线程保存到集合中
    public static void addServerConnectClientThread(String userId,ServerConnectClientThread scct){
        hm.put(userId,scct);
    }

    //静态方法，通过userId获取对应的ServerConnectClientThread线程
    public static ServerConnectClientThread getServerConnectClientThread(String userId){
        return hm.get(userId);
    }

    //静态方法，获取当前在线的用户
    public static String getKey(){
        Set<String> keySet = hm.keySet();
        String userList = "";
        for (String key :keySet) {
            userList += key + " ";
        }
        return userList;
    }

    //静态方法，移除相关线程
    public static void removeServerConnectClientThread(String userId){
        hm.remove(userId);
    }

}
